import request from "@/utils/request";
import {BillColumnMatchVO} from "./types";

/**
 * 保存账单项目配置
 *
 * @param data
 */
export function saveBillColumnMatch(data: BillColumnMatchVO) {
	return request({
		url: "/api/v1/billColumnMatch",
		method: "post",
		data: data,
	});
}

/**
 * 获取账单项目配置列表
 *
 * @param queryParams
 */
export function getBillColumnMatchList(platformKey: string) {
	return request({
		url: '/api/v1/billColumnMatch/' + platformKey + '/form',
		method: 'get'
	});
}

/**
 * 删除账单项目配置
 *
 * @param ids
 */
export function deleteBillColumn(ids: number) {
	return request({
		url: '/api/v1/billColumnMatch/' + ids,
		method: 'delete'
	});
}

/**
 * 导入账单项目配置
 *
 * @param file
 * @param platformKey
 */
export function billColumnMatchImport(file: File, platformKey: string) {
	const formData = new FormData();
	formData.append('file', file);
	return request({
		url: '/api/v1/billColumnMatch/billConfigImport/'+platformKey,
		method: 'post',
		data: formData,
		headers: {
			'Content-Type': 'multipart/form-data'
		}
	});
}

/**
 * 导出账单项目配置
 *
 * @returns
 */
export function billColumnMatchExport(platformKey: string) {
	return request({
		url: '/api/v1/billColumnMatch/billConfigExport/'+platformKey,
		method: 'get',
		responseType: 'arraybuffer'
	});
}

